package com.atguigu.gmall.seckill.controller;

import com.atguigu.gmall.common.result.Result;
import com.atguigu.gmall.model.activity.SeckillGoods;
import com.atguigu.gmall.seckill.service.SeckillService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * @author jzq
 * @create 2021-07-14 19:05
 */
@RestController
@RequestMapping("/seckill")
public class SeckillController {
    @Autowired
    private SeckillService seckillService;
    /**
     * 商品列表详情
     */
    @GetMapping("/list/{time}")
    public Result getSeckillGoods(@PathVariable(value = "time") String time){
        List<SeckillGoods> seckillGoods = seckillService.getSeckillGoods(time);
        return Result.ok(seckillGoods);
    }
    /**
     * 商品详情
     */
    @GetMapping("/product/list/{time}/{id}")
    public Result getSeckillproduct(@PathVariable(value = "time") String time,@PathVariable(value = "id") String id){
        SeckillGoods seckillGood = seckillService.getSeckillGood(time, id);
        return Result.ok(seckillGood);
    }

}
